﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace GraphicsFramework.Drawing.Primitive
{
    public class Line : BasePrimitive
    {

        public Line()
            : base(Enum.EnumDrawingType.LINE, "Draw Line", Enum.EnumMouseClicks.TWO)
        {
            Initialize(0, 0, 0, 0);
        }

        public Line(float x1, float y1, float x2, float y2)
            : base(Enum.EnumDrawingType.LINE, "Draw Line", Enum.EnumMouseClicks.TWO)
        {
            Initialize(x1, y1, x2, y2);
        }

        public Line(Entity.Point2F point1, Entity.Point2F point2)
            : base(Enum.EnumDrawingType.LINE, "Draw Line", Enum.EnumMouseClicks.TWO)
        {
            Initialize(point1.X, point1.Y, point2.X, point2.Y);
        }

        private void Initialize(float x1, float y1, float x2, float y2)
        {
            properties = Property.DefaultProperty.Common.Clone();

            points = new List<Entity.Point2F>();

            points.Add(new Entity.Point2F(x1, y1));
            points.Add(new Entity.Point2F(x2, y2));

            //Update the drawing after adding points.
            UpdateDrawing();
            UpdateCenter();

        }

        public override GraphicBase Clone()
        {
            Line graphic = new Line();

            //Clone base properties
            base.Clone(graphic);

            return graphic;
        }

        public override void UpdateGuide(List<Entity.Point2F> mousedown, Entity.Point2F mousemove)
        {
            Initialize(mousedown[0].X, mousedown[0].Y, mousemove.X, mousemove.Y);
        }

    }
}
